<?php
/*
 *      osuserinterface.php
 *      
 *      Copyright 2011 ViRak <vetalrakitin@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

//require_once($_SERVER['DOCUMENT_ROOT']."/classes/metadata/osmetadata.php");
//require_once($_SERVER['DOCUMENT_ROOT']."/classes/System/osdata.php");
//require_once($_SERVER['DOCUMENT_ROOT']."/classes/system.php");
require_once($_SERVER['DOCUMENT_ROOT']."/classes/interface/oslogin.php");
require_once($_SERVER['DOCUMENT_ROOT']."/classes/interface/oswindowmanager.php");
//@session_start();

/*
if (!array_key_exists("metadata", $_SESSION)) {
	$_SESSION["metadata"] = new osmetadata();
} else {
	if (!(get_class($_SESSION["metadata"]) == "osmetadata")) {
		$_SESSION["metadata"] = new osmetadata();
	}
}
	$metadata = &$_SESSION["metadata"];
	
if (!array_key_exists("data", $_SESSION)) {
	$_SESSION["data"] = new osdata();
} else {
	if (!(get_class($_SESSION["data"]) == "osdata")) {
		$_SESSION["data"] = new osdata();
	}
}
	$data = &$_SESSION["data"];
	
*/
	//$metadata->openfromfile("/home/vetal/openshift/meta.conf");
	
class osuserinterface extends oscomponent {
//class osuserinterface {
	//private $components = array();
	
	
	function __construct() {
		
		//$_SESSION["components"][$this->uuid]
/*
		$ret = "<div id=".$this->uuid;
		$ret .= " onload=message(this.id,'onload',0,0)";
		$ret .= ">";
		$ret .= "</div>";
		echo $ret;
*/
		//$_SESSION["userinterface"] = $this;
		//$_SESSION = null;
		//$_SESSION["components"] = null;
		//session_unset();
		$_SESSION["hooks"] = array();
		parent::__construct(0);
		$_SESSION["components"]["userinterface"] = $this;
		$_SESSION["components"]["windowmanager"] = new oswindowmanager(0);
		
		
		//$login = new oslogin(0);
		//	echo $login->get();
	}
	
/*
	function addcomponent($component, $parent) {
		if (get_class($component) == "oswindow") {
			
		}
		$this->components[$component->uuid] = $component;
	}
	
*/
/*
	function getchildren($parent) {
		
	}
*/

	function onload($height, $width) {
		//$this->height = $height;
		//$this->width = $width;
		$this->height = 800;
		$this->width = 1440;
		
		$_SESSION["components"]["login"] = new oslogin(0);
		//echo "onload";
	}
	
	function onresize($height, $width) {
		//$this->height = $height;
		//$this->width = $width;
		//echo "resize $height $width";
	}
	
/*
	function message($component, $function, $param1, $param2) {
		//if ()
		//$this->components[$component]->{$function}($param1,$param2);
		$_SESSION["components"][$component]->{$function}($param1,$param2);
		//echo $function;
	}
*/
	
/*
	function destroycomponent($component) {
		unset($this->components[$component->uuid]);
	}
*/

	function get() {
		//$ret = "<body scroll='no' id='".$this->uuid."' onload=message('".$this->uuid."','onload',document.height,document.width); onresize=message('".$this->uuid."','onresize',document.height,document.width);>";
		$ret = "<body scroll='no' id='".$this->uuid."' onload=message('".$this->uuid."','onload',document.height,document.width); onresize=message('".$this->uuid."','onresize',document.height,document.width);>";
		//$ret .= "<pre>".print_r($_SESSION,1)."</pre>";
		$ret .= "<div style='display:block;width:1440px;height:800px;background: #B6F5D9;'></div>";
		$ret .= "</body>";
		return $ret;
		//return $ret;
	}
}
?>
